package components.bullets.controller
{
	import components.bullets.Bullet;
	
	import flash.display.Bitmap;
	
	import res.DefaultResManager;

	public class BulletImageController
	{
		private var _isArrow:Boolean = true;
		protected var _bullet:Bullet;
		protected var _image:Bitmap;
		
		public function BulletImageController( bullet:Bullet )
		{
			_bullet = bullet;
			init();
		}
		
		private function init():void
		{
			_isArrow = !_bullet.vo.isAreaHit;
			if( _isArrow )
			{
				_image = new Bitmap( DefaultResManager.defaultArrowData );
				_image.x = -_image.width;
				_image.y = -int(_image.height/2);
			}
			else
			{
				_image = new Bitmap( DefaultResManager.defaultCannonballData );
				_image.x = -int(_image.width/2);
				_image.y = -int(_image.height/2);
			}
			_image.smoothing = true;
			_bullet.container.addChild( _image );
		}
		
		public function destroy():void
		{
			if( _image != null )
			{
				_image.bitmapData = null;
				if( _image.parent != null )
				{
					_image.parent.removeChild( _image );
				}
			}
		}
		
		public function refresh( time:int ):void
		{
			
		}
	}
}